<?php

require('header.php');
require('table_des_matieres.php');

if (isset($_POST["pics"]))
{
	
	echo "	<fieldset>
				<legend>".$language[$_SESSION['lang']]["Pics"]."</legend>";
				
	if (isset($_POST["Images"]))
	{
		echo '<form method="POST" enctype="multipart/form-data">
				  <input type="file" name="file" /><br />
				  <input type="hidden" name="pics" />
				  <input type="hidden" name="good" value="'.$_POST["good"].'"/>
				  <input type="submit" name="validerFile" value="'.$language[$_SESSION['lang']]["Valid"].'" >
				</form>';
	}
	else
	{	
		if (isset($extError))
		{
			echo '<fieldset style="float:left; clear:right;">'.$language[$_SESSION['lang']]["WrongExt"].'</fieldset><br /><br />';
		}
		elseif (isset($upload))
		{
			if ($upload)
			{
				echo '<fieldset style="float:left; clear:right;">'.$language[$_SESSION['lang']]["SuccessUpload"].'</fieldset><br /><br />';
			}
			else
			{
				echo '<fieldset style="float:left; clear:right;">'.$language[$_SESSION['lang']]["FailedUpload"].'</fieldset><br /><br />';
			}
		}
		
		echo '	<form method="POST">
					<input type="hidden" name="pics" />
					<input type="hidden" name="good" value="'.$_POST["good"].'"/>
					<input type="submit" name="Images" value="'.$language[$_SESSION['lang']]["AddPic"].'" />
				</form>';
	}
	
	$Directory = "Locations/".$_POST["good"]."/";
	
	if (is_dir($Directory) && $folder = opendir($Directory))
	{
		
		echo "<table class='managePicsTable'>";
		
		while ($file = @readdir($folder))
		{
			if (substr($file,strlen($file)-3,strlen($file)) == "png")
			{
				echo "	<tr>
							<td><img src='".$Directory.$file."' class='img256rounded'></td>
							<td>".$file."</td>";
				if (substr($file,0,4) != "oui_" && substr($file,0,4) != "non_")
				{
					
					echo "<td></td>";
					
				}
				else
				{
					if (substr($file,0,4) == "oui_")
					{
						
						echo "	<td>
									<form method='POST'>
										<input type='hidden' name='good' value='".$_POST["good"]."' />
										<input type='hidden' name='filename' value='".$file."' />
										<input type='hidden' name='pics' />
										<input type='submit' name='unauth' value='".$language[$_SESSION['lang']]["BlockPic"]."'>
										<input type='submit' name='default' value='".$language[$_SESSION['lang']]["MakeAsDefaultImg"]."'>";
						
					}
					else if (substr($file,0,4) == "non_")
					{
						
						echo "	<td>
									<form method='POST'>
										<input type='hidden' name='good' value='".$_POST["good"]."' />
										<input type='hidden' name='filename' value='".$file."' />
										<input type='hidden' name='pics' />
										<input type='submit' name='auth' value='".$language[$_SESSION['lang']]["UnBlockPic"]."'>";
						
					}
					
					echo "				<input type='submit' name='delete' value='".$language[$_SESSION['lang']]["DeletePic"]."'>
									</form>
								</td>";
					
				}				
						
				echo "	</tr>";
			}
		}
		
		echo "</table>";
		
		closeDir($folder);
	}
	
	echo "</fieldset>";
	
}
else if (isset($_POST["coms"]))
{
	
	foreach ($advices as $advice)
	{
		echo '	<fieldset style="clear:both;">
					<legend>'.$advice->titre_avis.'</legend>
					<div style="width:100%;">'.$advice->commentaire.'</div>
					<div style="float:right; text-align:right;"><img title="'.$advice->notation.'/10" src="CSS/Note/'.intval($advice->notation).'.png"/><br />
						<span style="font-size:12px;">'.$language[$_SESSION['lang']]["posted"].' '.date("d M Y",$advice->timestamp).' '.$language[$_SESSION['lang']]["By"].' '.$advice->utilisateur->nom.' '.$advice->utilisateur->prenom.'</span><br />
					 ';
		 
		if ($advice->last_updated > 0)
		{
			echo '<span style="font-size:12px;">'.$language[$_SESSION['lang']]["lastedition"].' '.date("d M Y",$advice->last_updated).'</span>';
		}
				
		echo '		</div>
				</fieldset>';
				
		echo '	<div>
					<form method="POST">
						<input type="hidden" name="good" value="'.$_POST["good"].'" />
						<input type="hidden" name="comId" value="'.$advice->id_avis.'" />
						<input type="hidden" name="coms" />';
				
		if ($advice->authorized)
		{		
			echo '		<input type="submit" name="unauth" value="'.$language[$_SESSION['lang']]["BlockCom"].'">';
		}
		else
		{
			echo '		<input type="submit" name="auth" value="'.$language[$_SESSION['lang']]["AllowCom"].'">';
		}
		
		echo '		</form>
				</div>';
		
	}
	
}
else
{
	
	echo '	<fieldset>
			<legend>'.$language[$_SESSION['lang']]["Address"].'</legend>

				<form method="POST">
				
				<input type="hidden" name="e-mail" />
				<input type="hidden" name="editer" />
				<input type="hidden" name="good" value="'.$_POST["good"].'" />';
				
	require('Views/adresse.php');
				
	echo '		<br />
				<input type="submit" name="valideradresse" value="'.$language[$_SESSION['lang']]["Valid"].'">
				
				</form>

			</fieldset>
			
			<fieldset>
				<legend>'.$language[$_SESSION['lang']]["Description"].'</legend>
				
				<div style="text-align:center">'.$language[$_SESSION['lang']]["DetailedDescription"].'</div>
				
				<form method="POST">
				<p>
				<img src="CSS/french.png" style="float:left; margin-top:84px;"/>
				<textarea style="float:left;" rows="12" cols="75" name="descriptionFr">';
				
	if (isset($descriptions["french"]))
	{
		echo str_replace("<br />","",$descriptions["french"]);
	}		
	
	echo '		</textarea>
				
				<textarea style="float:right;" rows="12" cols="75" name="descriptionEn">';
				
	if (isset($descriptions["english"]))
	{
		echo str_replace("<br />","",$descriptions["english"]);
	}
				
	echo '		</textarea>
				<img src="CSS/english.png" style="float:right; margin-top:84px;"/>
				
				</p>

				<input type="hidden" name="e-mail" />
				<input type="hidden" name="editer" />
				<input type="hidden" name="good" value="'.$_POST["good"].'" />
				<input type="submit" name="validerdescription" value="'.$language[$_SESSION['lang']]["Valid"].'" style="float:left; clear:both;">
			
				</form>
			
			</fieldset>';
	
}

require('footer.php');

?>
